import request from '@/utils/request'
import { encrypt, decrypt } from '@/utils/jsencrypt'
// 获取工单列表
export function callList(params) {
  return request({
    url: '/customer/call/record/list',
    method: 'get',
    params
  })
}
// 工单列表--删除
export function deleteCallList(id) {
  return request({
    url: '/customer/call/record/delete/' + id,
    method: 'post'
  })
}
// 登录方法
export function captchaLogin(username, password) {
  const data = {
    username,
    password: encrypt(password)
  }
  return request({
    url: '/auth/no/captcha/login',
    headers: {
      isToken: false
    },
    method: 'post',
    data
  })
}

// 电话记录单-基础信息 新增保存
export function listByCustomerFromView(data) {
  return request({
    url: '/customer/bizcustomer/listByCustomerFromView',
    method: 'post',
    data: data
  })
}

// 电话记录单-基础信息 新增保存
export function callRecordSave(data) {
  return request({
    url: '/customer/call/record/save',
    method: 'post',
    data: data
  })
}

// 电话记录单-基础信息 修改 保存
export function callRecordUpdate(data) {
  return request({
    url: '/customer/call/record/update',
    method: 'post',
    data: data
  })
}
// 电话记录单-获取详情
export function callRecordDetail(data) {
  return request({
    url: '/customer/call/record/detail/' + data,
    method: 'get'
  })
}
// 电话记录单-获取旧ERP发票列表
export function erpInvoiceRecord(params) {
  return request({
    url: '/crm/tel/record/invoice/list',
    method: 'get',
    params
  })
}
//问题分类下拉列表
export function questionTyplist(data) {
  return request({
    url: '/crm/knowledge/category/list',
    method: 'get',
    params: data
  })
}
//基础信息 -来电记录列表
export function recordList(data) {
  return request({
    url: '/crm/tel/record/list',
    method: 'get',
    params: data
  })
}

//基础信息 -获取基础信息

export function getDetailByCustomer(data) {
  return request({
    url: '/customer/call/record/getDetailByCustomer/' + data,
    method: 'get'
  })
}

//基础信息 -产品列表
export function productList(data) {
  return request({
    url: '/crm/tel/record/product/list',
    method: 'get',
    params: data
  })
}

export function getLevel(data) {
  return request({
    url: '/ord/order/ordordersync/get/member/level',
    method: 'post',
    data
  })
}

//获取电话设备列表
export function equipmentList(data) {
  return request({
    url: '/crm/tel/record/equipment/list',
    method: 'get',
    params: data
  })
}
//工单列表
export function dispatchList(data) {
  return request({
    url: '/crm/dispatch/list',
    method: 'get',
    params: data
  })
}

//邮件历史记录
export function mailList(data) {
  return request({
    url: '/system/mail/record/list',
    method: 'get',
    params: data
  })
}

//邮件历史记录--发送邮件
export function sendmail(data) {
  return request({
    url: '/system/mail/record/send/mail',
    method: 'post',
    data: data
  })
}

//短信模版-列表
export function templateList(data) {
  return request({
    url: '/system/sms/template/list',
    method: 'get',
    params: data
  })
}
//短信模版-详情
export function templateDetail(id) {
  return request({
    url: '/system/sms/template/get/' + id,
    method: 'get'
  })
}

//短信模版-保存修改
export function templateSave(data) {
  return request({
    url: '/system/sms/template/save',
    method: 'post',
    data
  })
}
//短信历史记录-列表
export function smsList(data) {
  return request({
    url: '/system/sms/record/list',
    method: 'get',
    params: data
  })
}
//短信历史记录-列表
export function sendSms(data) {
  return request({
    url: '/system/sms/record/send/sms',
    method: 'post',
    data
  })
}
//非现场单据-列表
export function offSiteList(data) {
  return request({
    url: '/crm/svc/off/site/service/list',
    method: 'get',
    params: data
  })
}

/********************异常单据**************/

// 电话记录单-基础信息 保存或者修改异常单据
export function abnormalSave(data) {
  return request({
    url: '/customer/abnormal/record/save',
    method: 'post',
    data: data
  })
}

//异常单据-列表
export function abnormalList(data) {
  return request({
    url: '/customer/abnormal/record/list',
    method: 'get',
    params: data
  })
}

//异常单据-列表 删除
export function deleteAbnormalList(id) {
  return request({
    url: '/customer/abnormal/record/delete/' + id,
    method: 'post'
  })
}
//异常单据-列表 详情
export function abnormalDeatils(id) {
  return request({
    url: '/customer/abnormal/record/get/' + id,
    method: 'get'
  })
}

/********************问题分类**************/

//问题分类-列表
export function knowledgelList(data) {
  return request({
    url: '/crm/knowledge/category/all/list',
    method: 'get',
    params: data
  })
}

// 问题分类保存或者修改
export function knowledgeSave(data) {
  return request({
    url: '/crm/knowledge/category/save',
    method: 'post',
    data: data
  })
}
//问题分类-列表 删除
export function deleteKnowledge(id) {
  return request({
    url: '/crm/knowledge/category/delete/' + id,
    method: 'post'
  })
}
